package com.zff.wechat.common;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.zff.web.util.GlobalConstants;
import com.zff.wechat.util.HttpUtils;

import net.sf.json.JSONObject;

public class WeChatTask {
	
	private static Logger LOG = Logger.getLogger(WeChatTask.class);
	
    public void getToken_getTicket() throws Exception {
        Map<String, String> params = new HashMap<String, String>();
        params.put("grant_type", "client_credential");
        params.put("appid", GlobalConstants.getInterfaceUrl("appid"));
        params.put("secret", GlobalConstants.getInterfaceUrl("AppSecret"));
        String jstoken = HttpUtils.sendGet(GlobalConstants.getInterfaceUrl("tokenUrl"), params);
        String access_token = JSONObject.fromObject(jstoken).getString("access_token");
        GlobalConstants.interfaceUrlProperties.put("access_token", access_token);
        LOG.info(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+" token:====================="+access_token);
    }

}
